package com.htudata.specialLink.service.impl ;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.htudata.common.enums.RequestSeqEnum;
import com.htudata.convention.domain.ResponseResult;
import com.htudata.core.util.ResultGenerator;
import com.htudata.specialLink.dao.SpecialLinkDao;
import com.htudata.specialLink.service.SpecialLinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SpecialLinkServiceImpl implements SpecialLinkService {

  @Autowired
  private SpecialLinkDao specialLinkDao;
  
  public JSONObject geNetworkStatusData() throws Exception {
    try {
      JSONArray arr = this.specialLinkDao.getSpecialLinkItems();
      JSONObject startPoint = this.specialLinkDao.getStartPoint();
      JSONObject result = new JSONObject(true);
      result.put("desc", "网络连接状态");
      result.put("endPoint", arr);
      result.put("startPoint", startPoint);
      return result;
    } catch (Exception e) {
       throw e;
    } 
  }
  
  public String geNetworkStatusDataJSON() throws Exception {
    ResponseResult responseResult = null;
    try {
      responseResult = ResultGenerator.genResult(RequestSeqEnum.SEQ_024.getCode(),
          geNetworkStatusData());
    } catch (Exception e) {
      throw e;
    }
    String result = JSON.toJSONString(responseResult);
    return result;
  }
}
